﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace HttpServer
{
    public partial class HttpApplication
    {
        public void ProcessRequest(HttpContent content ,Socket client)
        {
            string ext = Path.GetExtension(content.Reqeust.Url);
            if (ext==".aspx")
            {
                //表示请求动态资源
            }
            else
            {
                //请求静态资源
                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + content.Reqeust.Url))
                {
                    content.Response.Body = File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + content.Reqeust.Url);
                    client.Send(content.Response.Header);
                    client.Send(content.Response.Body);
                }
                else
                {
                    client.Send(content.Response.Header);
                }
                
            }
        }
    }
}
